package com.advertise.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.advertise.model.TreeNode;


@Entity
@Table(name="menu")
public class Menu extends TreeNode implements Serializable {
	private int id;
	private String menu;
	private String menuAction;

	private int parent;
	private int level;
	private Set<Role> roles;
	
	
	@ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
	@JoinTable(name="roleRights",joinColumns={@JoinColumn(name="menuId")},
			inverseJoinColumns={@JoinColumn(name="roleId")})

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public Menu(int id,String menu,int parent,int level){
		super(id, menu, parent, level);
		
		this.id	=	id;
		this.menu	=	menu;
		this.parent	=	parent;
		this.level	=	level;
		
	}
	
	public Menu(){
		
	}
	
	@Id
	@Column(name	=	"id",unique = true, nullable = false)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="menuName")
	public String getMenu() {
		return menu;
	}
	public void setMenu(String menu) {

		this.menu = menu;
	}
	
	@Column(name="parentId")
	public int getParent() {
		return parent;
	}
	public void setParent(int parent) {
		this.parent = parent;
	}
	
	@Column(name="level")
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	
	@Column(name="menuAction")
	public String getMenuAction() {
		return menuAction;
	}

	public void setMenuAction(String menuAction) {
		this.menuAction = menuAction;
	}
	
}
